package com.gy.universities.service.impl;
import com.gy.universities.dao.StudyCourseMapper;
import com.gy.universities.entity.StudyCourse;
import com.gy.universities.service.StudyCourseService;
//import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Component
@Service
public class StudyCourseServiceImpl implements StudyCourseService {

    @Resource
    private StudyCourseMapper studyCourseMapper;

    public StudyCourse getStudyCourseById(String id)throws Exception{
        return studyCourseMapper.getStudyCourseById(id);
    }

    public List<StudyCourse>	getStudyCourseListByMap(Map<String,Object> param)throws Exception{
        return studyCourseMapper.getStudyCourseListByMap(param);
    }

    public Integer getStudyCourseCountByMap(Map<String,Object> param)throws Exception{
        return studyCourseMapper.getStudyCourseCountByMap(param);
    }

    public Integer qdtxAddStudyCourse(StudyCourse studyCourse)throws Exception{
            //studyCourse.setCreatedTime(new Date());
            return studyCourseMapper.insertStudyCourse(studyCourse);
    }

    public Integer qdtxModifyStudyCourse(StudyCourse studyCourse)throws Exception{
        //studyCourse.setUpdatedTime(new Date());
        return studyCourseMapper.updateStudyCourse(studyCourse);
    }

    public Integer qdtxDeleteStudyCourseById(String id)throws Exception{
        return studyCourseMapper.deleteStudyCourseById(id);
    }

    public Integer qdtxBatchDeleteStudyCourse(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return studyCourseMapper.batchDeleteStudyCourse(param);
    }


}
